package com.outfood.config;

import com.outfood.intercept.LoginIntercept;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * 通用配置
 * 
 * @author platform
 */
@Configuration
public class CostomResourcesConfig implements WebMvcConfigurer
{



    @Resource
    LoginIntercept loginIntercept;

    /**
     * 自定义拦截规则
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(loginIntercept).addPathPatterns("/api/**").excludePathPatterns("/api/user/login").excludePathPatterns("/api/upload/**")
                .excludePathPatterns("/api/sign/**")
        ;

    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry)
    {
//        /** 本地文件上传路径 */
//        registry.addResourceHandler( "video/**")
//                .addResourceLocations("file:C:\\video/");

        /** swagger配置 */
        registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");

    }
}